// run: $exec < input
// opt: 0
// flag: -g
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>

struct data { int x, id; };
bool operator<(data const& a, data const& b)
{
	return a.x < b.x;
}

long long const mo = 1000000007;
int const maxn = 2000;
int tree[maxn][maxn];
int tmp[maxn];
std::vector<data> a;
int n, m;

int lowbit(int x) { return x & -x; }

long long query(int x, int id)
{
	long long ret = 0;
	for (; id > 0; id -= lowbit(id)) {
		ret += tree[x][id];
		ret %= mo;
	}
	return ret;
}

void update(int x, int id, long long d)
{
	for (; id <= n; id += lowbit(id)) {
		tree[x][id] += d;
		tree[x][id] %= mo;
	}
}

int main()
{
	std::ios::sync_with_stdio(false);
	int t; std::cin >> t;
	for (int ti = 1; ti <= t; ti++) {
		std::cout << "case #" << ti << ": ";
		std::cin >> n >> m;
		std::memset(tree, 0, sizeof(tree));
		a.resize(n);
		for (int i = 0; i < n; i++) {
			std::cin >> a[i].x;
			a[i].id = i + 1;
		}
		std::sort(a.begin(), a.end());

		for (int i = 0; i < (int)a.size(); i++) {
			tmp[1] = 1;
			int up = std::min(i + 1, m);
			int now = a[i].id;
			for (int j = 1; j < up; j++)
				tmp[j + 1] = query(j, now - 1);
			for (int j = 1; j <= i + 1; j++)
				update(j, now, tmp[j]);
		}

		long long ans = query(m, n);
		std::cout << ans << "\n";
	}
}

